// axios二次封装
import axios from 'axios'
import nprogress from 'nprogress'
import 'nprogress/nprogress.css'

//创建axios实例
const cateajax = axios.create({
    baseURL: '/item',//请求基本路径
    timeout: 5000 //超时时间
})
//请求拦截器
cateajax.interceptors.request.use((config) => {
    nprogress.start()
    return config
})
//响应拦截器
cateajax.interceptors.response.use(
    (response) => {
        nprogress.done()
        return response.data
    },
    (error) => {
        nprogress.done()
        alert(error)
        return new Promise(() => { })
    }
)
export default cateajax